package com.example.stars_project_android.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.stars_project_android.fragment.HomePageFragment;
import com.example.stars_project_android.fragment.MsgPageFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 消息fragment的适配器
 */
public class MsgAdapter extends FragmentStateAdapter {
    private List<String> mData = new ArrayList<>();

    public MsgAdapter(@NonNull FragmentActivity fragmentActivity, List<String> data) {
        super(fragmentActivity);
        mData = data;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return MsgPageFragment.newInstance(mData.get(position));
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }
}
